package com.yxdj.app.controller;

import com.yxdj.app.service.AppUserIndexService;
import com.yxdj.common.core.web.controller.BaseController;
import com.yxdj.common.core.web.domain.AjaxResult;
import com.yxdj.feedback.api.dto.UserReviewDto;
import com.yxdj.feedback.api.vo.UserReviewVo;
import com.yxdj.service.api.domain.MainCategory;
import com.yxdj.service.api.domain.ServiceDetail;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Tag(name = "App用户首页管理")
@RestController
@RequestMapping("/appUser")
public class AppUserIndexController extends BaseController {

    @Autowired
    private AppUserIndexService appUserIndexService;

    @Operation(summary = "App用户首页数据展示")
    @GetMapping("/index")
    public AjaxResult index() {
        Map<String,Object> map = appUserIndexService.index();
        return AjaxResult.success(map);
    }

    @Operation(summary = "查询所有分类")
    @GetMapping("/getAllCategory")
    public AjaxResult getAllCategory() {
        List<MainCategory> mainCategoryVoList = appUserIndexService.getAllCategory();
        return AjaxResult.success(mainCategoryVoList);
    }

    @Operation(summary = "根据id查询服务详情")
    @GetMapping("/getServiceDetailById/{id}")
    public AjaxResult getServiceDetailById(@PathVariable("id") Long id) {
        ServiceDetail serviceDetail = appUserIndexService.getServiceDetailById(id);
        return AjaxResult.success(serviceDetail);
    }

    @Operation(summary = "查询用户评价")
    @GetMapping("/getUserReview")
    public AjaxResult getUserReview(UserReviewDto userViewDto) {
        UserReviewVo userReviewVo = appUserIndexService.getUserReview(userViewDto);
        return AjaxResult.success(userReviewVo);
    }
}
